/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            aRoomDetailHisFeeInfo: {
                total: 0,
                records: 1,
                feeDetails: [],
                ownerId: '',
                feeId:'',
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            //切换 至费用页面
            vc.on('aRoomDetailHisFee', 'switch', function (_param) {
                $that.clearARoomDetailHisFeeInfo();
                if (_param.ownerId == '') {
                    return;
                }
                vc.copyObject(_param, $that.aRoomDetailHisFeeInfo)
                $that._listOwnerDetailFeeDetails(DEFAULT_PAGE, DEFAULT_ROWS);

            });
            vc.on('aRoomDetailHisFee', 'notify', function () {
                $that._listOwnerDetailFeeDetails(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('aRoomDetailHisFee', 'paginationPlus', 'page_event',
                function (_currentPage) {
                    $that._listOwnerDetailFeeDetails(_currentPage, DEFAULT_ROWS);
                });
        },
        methods: {
            _listOwnerDetailFeeDetails: function (_page, _row) {
                let param = {
                    params: {
                        page: _page,
                        row: _row,
                        ownerId: $that.aRoomDetailHisFeeInfo.ownerId,
                        feeId:$that.aRoomDetailHisFeeInfo.feeId,
                    }
                };

                //发送get请求
                vc.http.apiGet('/fee.queryAdminFeeDetail',
                    param,
                    function (json) {
                        let _json = JSON.parse(json);
                        $that.aRoomDetailHisFeeInfo.total = _json.total;
                        $that.aRoomDetailHisFeeInfo.records = _json.records;
                        $that.aRoomDetailHisFeeInfo.feeDetails = _json.feeDetails;
                        vc.emit('aRoomDetailHisFee', 'paginationPlus', 'init', {
                            total: $that.aRoomDetailHisFeeInfo.records,
                            dataCount: $that.aRoomDetailHisFeeInfo.total,
                            currentPage: _page
                        });
                    },
                    function () {
                        console.log('请求失败处理');
                    }
                );
            },

            clearARoomDetailHisFeeInfo: function () {
                $that.aRoomDetailHisFeeInfo = {
                    total: 0,
                    records: 1,
                    feeDetails: [],
                    ownerId: '',
                    feeId:''
                }
            },
        }
    });
})(window.vc);